class Solution {
    public int findMin(int[] nums) {
        int left = 0;
        int length = nums.length;
        int right = length-1;
        //先将前面和最后一个元素重复的数据剔除，剩下的元素和最后一个元素比较 是否 <=最后一个元素，结果就是单调的了
        for(int i=0; i<length; i++){
            if(nums[i]==nums[length-1]){
                left++;
            }else{
                break;
            }
            
        }
        while(left < right){
            int mid = (left+right)>>1;
            if(nums[mid]<=nums[length-1]){
                right = mid;
            }else{
                left = mid+1;
            }
        }
        return nums[right];
    }
}
